package com.gk.company.view.top
{
	import com.gk.app.GT;
	import com.gk.app.Language;
	import com.gk.company.view.upgrade.UpgradeCompanyView;
	import com.gk.init.model.vo.UserInfoVo;
	import com.gk.util.GameSprite;
	import com.gk.util.component.HBox;
	import com.gk.util.component.Label;
	import com.gk.util.component.LabelButton;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;

	/**
	 *头部用户信息 
	 * @author Nestor
	 * 
	 */	
	public class TopInfoView extends GameSprite
	{
		private var picCt:Sprite;//头像
		private var nameLabel:Label;//昵称
		
		private var lvLabel:Label;//等级称号
		private var lvValue:Label;//等级数值
		
		private var kBLabel:Label;//K币
		private var kBValue:Label;//K币数值
		
		private var mBLabel:Label;//金币
		private var mbValue:Label;//金币数值
		
		private var popularLabel:Label;//知名度
		private var popularValue:Label;//知名度数值
		private var upgradeBtn:LabelButton;//升级按钮
		
		public function TopInfoView(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0)
		{
			super(parent,xpos,ypos);
			var dobj:DisplayObject;
			
			picCt = GT.getRectGraphic(70,70,0,0,0,1,0.5);
			dobj = addChild(picCt);
			
			this.nameLabel = new Label(this,0,75);
			
			lvLabel = new Label(this,100,0,"小型公司");
			lvValue = new Label(this,lvLabel.x+lvLabel.width+5,0,"lv1");
			
			kBLabel = new Label(this,300,0,Language.COMPANY_TOP_INFO[0]);
			kBValue = new Label(this,kBLabel.x+kBLabel.width+5,0,"888888");
			
			mBLabel = new Label(this,450,0,Language.COMPANY_TOP_INFO[1]);
			mbValue = new Label(this,mBLabel.x+mBLabel.width+5,0,"88888888");
			
			popularLabel = new Label(this,100,35,Language.COMPANY_TOP_INFO[2]);
			popularValue = new Label(this,popularLabel.x+popularLabel.width+5,35,"8888888888");
			
			upgradeBtn = new LabelButton(this,popularValue.x+popularValue.width+5,35,"升级",upgradeHandler);
			upgradeBtn.setSize(35,20);
			
		}
		
		private function upgradeHandler(e:MouseEvent):void
		{
			GT.popupWindow(new UpgradeCompanyView());
			
		}
		/**
		 *更新头部信息 
		 * @param url
		 * @param name
		 * 
		 */		
		public function updateInfo(url:String,name:String):void{
			nameLabel.text = name;
			nameLabel.move(picCt.width/2 - nameLabel.width /2,picCt.y+75);
			GT.getImage(picCt,url,true,70,70);
		
		}
		/**
		 *更新K币 
		 * 
		 */
		public function updateKB(v:uint):void{
			kBValue.text = v.toString();
		}
		/**
		 *更新金币 
		 * 
		 */
		public function updateMB(v:uint):void{
			mbValue.text = v.toString();
		}
		/**
		 *更新知名度 
		 * @param v
		 * 
		 */		
		public function updatePopular(v:uint):void{
			popularValue.text = v.toString();
			upgradeBtn.x = popularValue.x+popularValue.width+5;
		}
		/**
		 *更新全部信息 
		 * @param v
		 * 
		 */		
		public function updateAllInfo(v:UserInfoVo):void{
			updateKB(v.kbNum);
			updateMB(v.mbNum);
			updatePopular(v.popularNum);
			updateInfo(v.user_pic,v.user_name);
		}
		/**
		 *改变升级按钮可见度 
		 * @param v
		 * 
		 */		
		public function changeUpgrade(v:Boolean):void{
			this.upgradeBtn.visible = v;
		}
	}
}